<?php
    define('SIDEBAR_LINK', '<li><a%s href="' . SYS_BASE_URL .  '/%s">%s</a></li>');
    
    function generateSidebar($json, $suffix = '', $selection = null){
    	$arr = json_decode($json, true);
    	$cnt = 0;
    	$con = '';
    	
    	foreach($arr as &$val){
    		$con .= sprintf(SIDEBAR_LINK, 
	    			$selection == $cnt++ ? ' class="selected"' : '', 
	    			$val['href'] . $suffix, $val['text']);
	    	$con .= "\n";
    	}
    	
    	return $con;
    }
